package com.lvhx.task;

import com.lvhx.dao.OrderMapper;
import com.lvhx.pojo.Order;
import com.lvhx.service.TestServiceImpl;
import com.lvhx.utils.DataAccessManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

public class TestJob implements Callable<String> {

    private static final Logger logger = LoggerFactory.getLogger(TestJob.class);

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String call() throws Exception {
        TestServiceImpl bean = DataAccessManager.getBean(TestServiceImpl.class);

        logger.info("任务开始执行：" + Thread.currentThread().getName() + ":" + name);

        TimeUnit.SECONDS.sleep(5);

        logger.info("任务执行完成：" + Thread.currentThread().getName() + ":" + name);

//        throw new RuntimeException("任务执行异常");

        Order order = DataAccessManager.getBean(OrderMapper.class).selectByPrimaryKey("1");

        return null;
    }
}
